package cn.jlonely.xyhx.app.controller;


import cn.jlonely.xyhx.app.service.AppReviewService;
import cn.jlonely.xyhx.pojo.Review;
import cn.jlonely.xyhx.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/app")
public class AppReviewController {
    @Autowired
    private AppReviewService appReviewService;


    /***
     * 查看详细排名信息
     * @param id
     * @return
     */
    @GetMapping("/getReviewInfo")
    public Result getReviewInfo(@RequestParam("id") Integer id) {

        List<Review> reviews = appReviewService.getReviewInfo(id);

        return Result.success(reviews);
    }

    /**
     * 加入活动
     *
     * @param review
     * @return
     */

    @PostMapping("creatReview")
    public Result creatReview(@RequestBody Review review) {
        try {
            appReviewService.creatReview(review);
            return Result.success();
        } catch (Exception e) {
            return Result.error("您已经参加过该活动");
        }

    }


}
